<!DOCTYPE html>
<html>
<head>
    <title>添加收费项目--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="../Js/webUtil.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">
    $(function () {
        let url = document.location.toString();
        let index = url.GetValue("index");
		$('#backid').click(function(){
				window.location.href="charge.html?index="+index;
		 });
    });
    </script>
</head>
<body>
<form id="chargeForm" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">编号</td>
        <td ><input name="id" id="id" value=""/></td>

    </tr>
    <tr>
        <td width="10%" class="tableleft">收费项目名称</td>
        <td><input id="name" name="name" type="text" value="心电图图检" /></td>
    </tr>

    <tr>
        <td width="10%" class="tableleft">收费金额</td>
        <td><input id="money" type="text" name="money" value="600"/></td>
    </tr>
    <tr>
        <td colspan="2">
			<center>
				<button id="update" class="btn btn-primary" type="button">保存</button> &nbsp;&nbsp;
                <button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
</body>
<script>
$(function () {
    loadData();
    let url = document.location.toString();
    let state = url.GetValue("state");
    if (state==0){
        $("#id").attr("disabled","disabled");
        $("#name").attr("disabled","disabled");
        $("#money").attr("disabled","disabled");
        $("#keep").hide();
    }
    $("#update").click(function(){
       update();
    });
});

function update(){
    let url = document.location.toString();
    let index = url.GetValue("index");
    if ($("#name").val().length==0){
        alert("请输入项目名称！");
        return;
    }
    if ($("#money").val().length==0){
        alert("请输入收费金额！");
        return;
    }
    $.ajax({
        type:"POST",
        url:"/chargeProject",
        data:$("#chargeForm").serialize()+"&_method=PUT",
        dataType:"json",
        success: function(vo){
            alert(vo.msg);
            window.location.href="charge.html?index="+index;
        }
    });
}
function loadData() {
    let url = document.location.toString();
    let id = url.GetValue("id");
    $.ajax({
       type:"GET",
       url:"/chargeProject/"+id,
       data:"",
       dataType:"json",
       success: function (vo) {
           if (vo.code ==200){
               let obj = vo.obj;
               $("#id").val(obj.id);
               $("#name").val(obj.name);
               $("#money").val(obj.money);
           }else{
               alert(vo.msg);
           }
       }
    });
}
</script>
</html>